﻿using Corina.Datamodel.Base;
using Corina.Datamodel.Interface;
using Corina.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace Corina.Datamodel.Entities
{
    [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
    [DataContract]
    public class ThirdPartyMeasureInfo : DatamodelEntity, IThirdPartyMeasure
    {
        #region Fields
        private int _id;
        private int _userId = 0;
        private string _applicant;
        private string _applyUnit;
        private DateTime _applyDate = DateTime.Now;
        private string _specimen;
        private int _specimenKindId = 0;
        private string _measureObject;
        private double _density = 0;
        private string _densityUnit = "ppm";
        private double _humidity = 0;
        private double _temperature = 0;
        private DateTime _measureTime = DateTime.Now;
        private string _measureDevice;
        private string _tester;
        private DateTime _submitTime = DateTime.Now;
        #endregion

        #region Properties
        [DataMember]
        public int Id
        {
            get { return _id; }
            set
            {
                _id = value;
                RaisePropertyChanged(() => Id);
            }
        }

        [DataMember]
        public int UserId
        {
            get { return _userId; }
            set
            {
                _userId = value;
                RaisePropertyChanged(() => UserId);
            }
        }

        [DataMember]
        public string Applicant
        {
            get { return _applicant; }
            set
            {
                _applicant = value;
                RaisePropertyChanged(() => Applicant);
            }
        }

        [DataMember]
        public string ApplyUnit
        {
            get { return _applyUnit; }
            set
            {
                _applyUnit = value;
                RaisePropertyChanged(() => ApplyUnit);
            }
        }

        [DataMember]
        public DateTime ApplyDate
        {
            get { return _applyDate; }
            set
            {
                _applyDate = value;
                RaisePropertyChanged(() => ApplyDate);
            }
        }

        [DataMember]
        public string Specimen
        {
            get { return _specimen; }
            set
            {
                _specimen = value;
                RaisePropertyChanged(() => Specimen);
            }
        }

        [DataMember]
        public int SpecimenKindId
        {
            get { return _specimenKindId; }
            set {
                _specimenKindId = value;
                RaisePropertyChanged(() => SpecimenKindId);
            }
        }

        [DataMember]
        public string MeasureObject
        {
            get { return _measureObject; }
            set
            {
                _measureObject = value;
                RaisePropertyChanged(() => MeasureObject);
            }
        }

        [DataMember]
        public double Density
        {
            get { return _density; }
            set
            {
                _density = value;
                RaisePropertyChanged(() => Density);
            }
        }

        [DataMember]
        public string DensityUnit
        {
            get { return _densityUnit; }
            set
            {
                _densityUnit = value;
                RaisePropertyChanged(() => DensityUnit);
            }
        }

        [DataMember]
        public double Humidity
        {
            get { return _humidity; }
            set
            {
                _humidity = value;
                RaisePropertyChanged(() => Humidity);
            }
        }

        [DataMember]
        public double Temperature
        {
            get { return _temperature; }
            set
            {
                _temperature = value;
                RaisePropertyChanged(() => Temperature);
            }
        }

        [DataMember]
        public DateTime MeasureTime
        {
            get { return _measureTime; }
            set
            {
                _measureTime = value;
                RaisePropertyChanged(() => MeasureTime);
            }
        }

        [DataMember]
        public string MeasureDevice
        {
            get { return _measureDevice; }
            set
            {
                _measureDevice = value;
                RaisePropertyChanged(() => MeasureDevice);
            }
        }

        [DataMember]
        public string Tester
        {
            get { return _tester; }
            set
            {
                _tester = value;
                RaisePropertyChanged(() => Tester);
            }
        }

        [DataMember]
        public DateTime SubmitTime
        {
            get { return _submitTime; }
            set
            {
                _submitTime = value;
                RaisePropertyChanged(() => SubmitTime);
            }
        }

        #endregion

        protected override IEnumerable<DatabaseColumn> InitColumns()
        {
            yield return new DatabaseColumn("Id", true);
            yield return new DatabaseColumn("UserId", false, true);
            yield return new DatabaseColumn("Applicant");
            yield return new DatabaseColumn("ApplyUnit");
            yield return new DatabaseColumn("ApplyDate");
            yield return new DatabaseColumn("Specimen");
            yield return new DatabaseColumn("SpecimenKindId");
            yield return new DatabaseColumn("MeasureObject");
            yield return new DatabaseColumn("Density");
            yield return new DatabaseColumn("DensityUnit");
            yield return new DatabaseColumn("Humidity");
            yield return new DatabaseColumn("Temperature");
            yield return new DatabaseColumn("MeasureTime");
            yield return new DatabaseColumn("MeasureDevice");
            yield return new DatabaseColumn("Tester");
            yield return new DatabaseColumn("SubmitTime", false, true);
        }
    }
}